<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/commons/js/uploadify/jquery.uploadify.min.js"></script>
<link type="text/css" href="${ctx}/commons/js/uploadify/uploadify.css" rel="stylesheet" />
<style>
	.lg_tag{
		font-size: 14px;
    	font-weight: bold;
	}
	.fs_box{
		margin: 10px 10px;
    	padding: 10px 10px;
	}

</style>
<div style="padding:20px 20px;">
	<form id="signForm">
		<input type="hidden" name="auctionId" value="${auctionId}"/>
		<input type="hidden" name="auctionName" value="${auctionName}"/>
		<input type="hidden" name="regId" value="${regId}"/>
		<input type="hidden" name="regName" value="${regName}"/>
		<input type="hidden" name="regTime" value="${regTime}"/>
		<input type="hidden" name="status" value="${status}"/>
        <fieldset class="fs_box">
			<legend class="lg_tag">报名资料上传</legend>
			<input type="file" name="uploadify" id="uploadify" data-options="required:true" >
			<p style="color: #aaaaaa;width: auto">
				* 请上传一个.rar文件
			</p>
		</fieldset>
	</form>
</div>
<script type="text/javascript">
    $(function(){
        // $(".uploadify").each(function() {
        //     fileQueue=$(this).parent().find(".fileQueue");
        //     // alert(upload.val());
            $("#uploadify").uploadify({
                'height'        : 27,
                'width'         : 80,
                'buttonText'    : '选择附件',
                'queueID': $(this).parent().find(".fileQueue").val(),//队列的ID
                'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
                'uploader':'${ctx}/auction/business/regAudit/upload;jsessionid=${pageContext.session.id}',// 上传时请求的后台处理的controller
                'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
                'method':'post',
                'folder': '',
                'preventCaching' : true,
                'fileTypeExts' :'*.rar;',
				'fileSizeLimit':'102400',	//100M
                'auto': true,
                'queueSizeLimit':999,
				'uploadLimit':1,
                'multi': false,//是否可多选
                'removeCompleted' : false,
                'successTimeout' : 55555,
                'onUploadSuccess':function(file, data, response){
                    $('#' + file.id).find('.data').html(' 上传完毕');
                    $('#uploadify').val($('#uploadify').val() + data);
                    //alert("ww"+$('#' + file.id).parent().html());
                    var cancel=$('.fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
                    if (cancel) {
                        cancel.attr("rel", data);
                        cancel.click(function () {
                            var cancelData = cancel.attr("rel");
                            var  budgetMenuData = $('#budgetMenuData').val();
                            var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
                            if(index != -1){
                                budgetMenuData = budgetMenuData.replace(","+cancelData,"");
                                $('#budgetMenuData').val(budgetMenuData);
                            }
                        });
                    }
                },
                'onUploadStart':function(file){
                    //alert("ww"+$('#' + file.id).parent().parent().find(".uploadify").attr("id"));
                    var uploadId=$('#' + file.id).parent().parent().find(".uploadify").attr("id");
                    //var params=$('#' + file.id).parent().parent().parent().parent().find(".fileName").val();
                    var functionFlog=$('#' + file.id).parent().parent().parent().parent().find(".fileQueue").attr("flag");
                    $("#"+uploadId).uploadify("settings","formData",{"functionFlog":functionFlog});
                },
                // 'onUploadError':function(e, i, h) {
                //     switch(i) {
                //         case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:;
                //             break;
                // },
                'onSelectError':function(file, errorCode, errorMsg){
					//alert(errorCode);

                    switch(errorCode) {
                        case -100:
                            this.queueData.errorMsg='请上传一个.rar文件!';
                            break;
                        case -110:
                            this.queueData.errorMsg='所选文件大小超出系统限制!';
                            break;
                        case -120:
                            this.queueData.errorMsg='所选文件大小异常!';
                            break;
                        case -130:
                            this.queueData.errorMsg='所选文件类型不正确!';
                            break;
                    }
                },
                'onCancel' : function(file){
                    // alert(file);
                }
            });
        // });

	});

</script>